///BEGIN PHP PLATFORM ==========
#if defined(PLATFORM_PHP)
#define SERVICE_DIR 					SESSION("service_dir")
#define SET_SERVICE_DIR(dir) 			{SERVICE_DIR=dir;}

#define SERVICE_NAME(name)				('svc_'.name)
#define FORM_NAME(name)					('frm_'.name)
#define PATTERN_NAME(name)				('ptn_'.name)

#define API_DIR 						SERVICE_DIR.'/../'
#define PATTERN_DIR						SERVICE_DIR.'/pattern/'
#define PATTERN_FILE(a) 				PATTERN_DIR.'ptn_'.a.'.php'
#define FORM_FILE(a)					PATTERN_DIR.FORM_NAME(a).'.php'
#define SERVICE_FILE(name) 				PATTERN_DIR.SERVICE_NAME(name).'.php'


#define APP_DIR							SERVICE_DIR.'/../Application/'
#define GET_APP_DIR(appid)				APP_DIR.FunctionApp::getAppDirectory(appid).'/'
#define APP_SERVICE_FILE(appid,name)	GET_APP_DIR(appid).SERVICE_NAME(name).'.php'
#define APP_PATTERN_DIR(appid)			GET_APP_DIR(appid).'pattern/'
#define APP_PATTERN_FILE(appid,fname)	APP_PATTERN_DIR(appid).PATTERN_NAME(fname).'.php'
#define APP_FORM_FILE(appid,fname)		APP_PATTERN_DIR(appid).FORM_NAME(fname).'.php'

#define IMAGE_DIR						'images/'
#define APP_IMAGE_DIR(appid)			GET_APP_DIR(appid).'images/'				

#define REQUIRE(file)					require_once(file)
#define REQUIRE_API(api)				REQUIRE(API_DIR.api)
#define REQUIRE_APP_API(appid,api)		REQUIRE(GET_APP_DIR(appid).'/'.api)

#define PATTERN_CREATE(ptn,pattern_str)	{ptn = new Util\str\Pattern(pattern_str);}
#define PATTERN_PUBLISH(ptn)			ptn->publish()
#define PATTERNMNG_CREATE(ptnmng,file)		{ptnmng = new Util\str\PatternManager(file);}

#define STATISTIC_FILTER_FULL			0xFFFFFFFF
#define STATISTIC_FILTER_GLOBAL			(1<<0)
#define STATISTIC_FILTER_ACCOUNT		(1<<1)
#define STATISTIC_FILTER_ACCOUNTS		(1<<2)
#define STATISTIC_FILTER_AREA			(1<<3)
#define STATISTIC_FILTER_AREAS			(1<<4)
#define STATISTIC_FILTER_GROUP			(1<<5)
#define STATISTIC_FILTER_GROUPS			(1<<6)
#define STATISTIC_FILTER_APP			(1<<7)
#define STATISTIC_FILTER_APPS			(1<<8)

#define STATISTIC(a) 					STATISTIC_FILTER_##a

#define ERROR_OBJ						Error::getInstance()
#define ERROR_ADD(code,message) 		{ERROR_OBJ->addError(code,message);}
#define ERROR_GET(obj)					{obj = ERROR_OBJ->error;}

#define PUBLISH_RESULT(rs,lang)			rs->publish(lang)		

#define TOOL_BUTTON(area,license,type,action,title,icon)	array('license_area'=>area,'license_role'=>license,'type'=>type,'action'=>action,'title'=>title,'icon'=>icon)	
#endif //PLATFORM_PHP
///END PHP PLATFORM ==========